<template>
  <div class="main">
    <van-loading type="spinner" v-if="loading" />
  </div>
</template>
<script>
export default {
  name: "payLoding",
  data() {
    return {
      loading: true,
      version: 0,
      currentQuery: "",
      url: "",
    };
  },
  mounted() {
    this.version = window.location.href;
    // console.log('info', this.$route.params.info)
    this.url = !this.getParam("wechatUrl") ? "" : this.getParam("wechatUrl");
    let redirectUrl = 'https://debug.yasee.com.cn:9035/#/payComplete';
    let encodedRedirectUrl = encodeURIComponent(redirectUrl);
    this.url = `${decodeURIComponent(this.url)}+&redirect_url=${encodedRedirectUrl}`;
    // this.url = `${decodeURIComponent(this.url)}`;
    if (this.url) {
      this.loading = false;
      window.location.href = this.url;
    }
  },
  methods: {
    // 获取参数
    getParam(name) {
      if (this.version.indexOf("?") != -1) {
        const query = this.version.split("?")[1];
        const vars = query.split("&");
        for (var i = 0; i < vars.length; i++) {
          var pair = vars[i].split("=");
          if (pair[0] == name) {
            return pair[1];
          }
        }
      } else {
        return "";
      }
    },
  },
};
</script>

<style scoped lang="less">
.main {
  height: 100vh;
  display: flex;
  justify-content: center;
  align-items: center;
}
</style>
